package icu.funkye.controller;

import com.hbuzzs.springcloud.entities.OrderInfo;
import icu.funkye.service.IOrderInfoService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.time.LocalDateTime;

/**
 * @author funkye
 */
@RestController
@Slf4j
public class OrderController {

    @Autowired
    private IOrderInfoService ordersService;

    @PostMapping("/save")
    public boolean save(@RequestBody OrderInfo orders) {
        orders.setOrderTime(LocalDateTime.now());
//        throw new RuntimeException();
        return ordersService.save(orders);
    }

    @GetMapping("/get/{id}")
    public OrderInfo save(@PathVariable("id") int id) {
        return ordersService.getById(id);
    }
}
